/**************************************************************************//**
 * @file           main.c
 * @version        V1.0
 * $Revision:      1 $
 * $Date:          2017/01/04 $
 * @brief          Main function
 * @Author         Jeffrey Kang
 * @ContactInfo    chkang@esmt.com.tw
 *
 * @note
 *
 * Copyright (C) 1998 Elite Semiconductor Memory Technology Corp.
 * All rights reserved.
 *
 ******************************************************************************/


#include <REG52.h>
#include "system_FE81001.h"


/**
 * @brief       delay function
 *
 * @param       None
 *
 * @return      None
 *
 * @details     1. 
 */
void delay (int cnt )
{
	unsigned int i , j ;
	
	for(j=0 ; j<cnt ; j++)
	for( i = 0 ; i < 200 ; i++ ); 
	
}


/**
 * @brief       ClkInit function
 *
 * @param       None
 *
 * @return      None
 *
 * @details     1. 
 */
void Clock_Config(void)
{
	PORT_PAPBPCPD_Clock_Enable();
}


void IOConfig()
{
	/* Set PC7 input as button */
	PORT_SetPCInput(BIT7);

	/* Set PD1. ,PD2.,PD3 output */
	PORT_SetPDPushPull(BIT1 | BIT2 | BIT3 );
}


/**
 * @brief       main function
 *
 * @param       None
 *
 * @return      None
 *
 * @details     1. 
 */
int main( void )
{
	Clock_Config();
	IOConfig();
	
	PD1 = 0; // LED_G1 On
	PD2 = 1 ; //LED_R Off
	PD3= 0;  // LED_G2  On

	
	while(1)
	{
    	if( Get_PCx_input(7) == 0)   // PC7  = 0 , button down
			{
					PD2 = 0 ; //LED_R On
			}
			else
			{
					PD2 = 1 ; //LED_R Off
			}
	}
}

